{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useEventCallback as useEventCallback } from '@mui/utils';\nimport extractEventHandlers from '../utils/extractEventHandlers';\n\n/**\n * The basic building block for creating custom snackbar.\n *\n * Demos:\n *\n * - [Snackbar](https://mui.com/base/react-snackbar/)\n */\nexport default function useSnackbar(parameters) {\n  const {\n    autoHideDuration = null,\n    disableWindowBlurListener = false,\n    onClose,\n    open,\n    ref,\n    resumeHideDuration\n  } = parameters;\n  const timerAutoHide = React.useRef();\n  React.useEffect(() => {\n    if (!open) {\n      return undefined;\n    }\n\n    /**\n     * @param {KeyboardEvent} nativeEvent\n     */\n    function handleKeyDown(nativeEvent) {\n      if (!nativeEvent.defaultPrevented) {\n        // IE11, Edge (prior to using Blink?) use 'Esc'\n        if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {\n          // not calling `preventDefault` since we don't know if people may ignore this event e.g. a permanently open snackbar\n          onClose == null ? void 0 : onClose(nativeEvent, 'escapeKeyDown');\n        }\n      }\n    }\n    document.addEventListener('keydown', handleKeyDown);\n    return () => {\n      document.removeEventListener('keydown', handleKeyDown);\n    };\n  }, [open, onClose]);\n  const handleClose = useEventCallback((event, reason) => {\n    onClose == null ? void 0 : onClose(event, reason);\n  });\n  const setAutoHideTimer = useEventCallback(autoHideDurationParam => {\n    if (!onClose || autoHideDurationParam == null) {\n      return;\n    }\n    clearTimeout(timerAutoHide.current);\n    timerAutoHide.current = setTimeout(() => {\n      handleClose(null, 'timeout');\n    }, autoHideDurationParam);\n  });\n  React.useEffect(() => {\n    if (open) {\n      setAutoHideTimer(autoHideDuration);\n    }\n    return () => {\n      clearTimeout(timerAutoHide.current);\n    };\n  }, [open, autoHideDuration, setAutoHideTimer]);\n  const handleClickAway = event => {\n    onClose == null ? void 0 : onClose(event, 'clickaway');\n  };\n\n  // Pause the timer when the user is interacting with the Snackbar\n  // or when the user hide the window.\n  const handlePause = () => {\n    clearTimeout(timerAutoHide.current);\n  };\n\n  // Restart the timer when the user is no longer interacting with the Snackbar\n  // or when the window is shown back.\n  const handleResume = React.useCallback(() => {\n    if (autoHideDuration != null) {\n      setAutoHideTimer(resumeHideDuration != null ? resumeHideDuration : autoHideDuration * 0.5);\n    }\n  }, [autoHideDuration, resumeHideDuration, setAutoHideTimer]);\n  const createHandleBlur = otherHandlers => event => {\n    const onBlurCallback = otherHandlers.onBlur;\n    onBlurCallback == null ? void 0 : onBlurCallback(event);\n    handleResume();\n  };\n  const createHandleFocus = otherHandlers => event => {\n    const onFocusCallback = otherHandlers.onFocus;\n    onFocusCallback == null ? void 0 : onFocusCallback(event);\n    handlePause();\n  };\n  const createMouseEnter = otherHandlers => event => {\n    const onMouseEnterCallback = otherHandlers.onMouseEnter;\n    onMouseEnterCallback == null ? void 0 : onMouseEnterCallback(event);\n    handlePause();\n  };\n  const createMouseLeave = otherHandlers => event => {\n    const onMouseLeaveCallback = otherHandlers.onMouseLeave;\n    onMouseLeaveCallback == null ? void 0 : onMouseLeaveCallback(event);\n    handleResume();\n  };\n  React.useEffect(() => {\n    // TODO: window global should be refactored here\n    if (!disableWindowBlurListener && open) {\n      window.addEventListener('focus', handleResume);\n      window.addEventListener('blur', handlePause);\n      return () => {\n        window.removeEventListener('focus', handleResume);\n        window.removeEventListener('blur', handlePause);\n      };\n    }\n    return undefined;\n  }, [disableWindowBlurListener, handleResume, open]);\n  const getRootProps = function () {\n    let otherHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n    const propsEventHandlers = extractEventHandlers(parameters);\n    const externalEventHandlers = _extends({}, propsEventHandlers, otherHandlers);\n    return _extends({\n      ref,\n      // ClickAwayListener adds an `onClick` prop which results in the alert not being announced.\n      // See https://github.com/mui/material-ui/issues/29080\n      role: 'presentation'\n    }, externalEventHandlers, {\n      onBlur: createHandleBlur(externalEventHandlers),\n      onFocus: createHandleFocus(externalEventHandlers),\n      onMouseEnter: createMouseEnter(externalEventHandlers),\n      onMouseLeave: createMouseLeave(externalEventHandlers)\n    });\n  };\n  return {\n    getRootProps,\n    onClickAway: handleClickAway\n  };\n}","map":{"version":3,"names":["_extends","React","unstable_useEventCallback","useEventCallback","extractEventHandlers","useSnackbar","parameters","autoHideDuration","disableWindowBlurListener","onClose","open","ref","resumeHideDuration","timerAutoHide","useRef","useEffect","undefined","handleKeyDown","nativeEvent","defaultPrevented","key","document","addEventListener","removeEventListener","handleClose","event","reason","setAutoHideTimer","autoHideDurationParam","clearTimeout","current","setTimeout","handleClickAway","handlePause","handleResume","useCallback","createHandleBlur","otherHandlers","onBlurCallback","onBlur","createHandleFocus","onFocusCallback","onFocus","createMouseEnter","onMouseEnterCallback","onMouseEnter","createMouseLeave","onMouseLeaveCallback","onMouseLeave","window","getRootProps","propsEventHandlers","externalEventHandlers","role","onClickAway"],"sources":["/data/messenger.client/node_modules/@mui/lab/node_modules/@mui/base/SnackbarUnstyled/useSnackbar.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useEventCallback as useEventCallback } from '@mui/utils';\nimport extractEventHandlers from '../utils/extractEventHandlers';\n\n/**\n * The basic building block for creating custom snackbar.\n *\n * Demos:\n *\n * - [Snackbar](https://mui.com/base/react-snackbar/)\n */\nexport default function useSnackbar(parameters) {\n  const {\n    autoHideDuration = null,\n    disableWindowBlurListener = false,\n    onClose,\n    open,\n    ref,\n    resumeHideDuration\n  } = parameters;\n  const timerAutoHide = React.useRef();\n  React.useEffect(() => {\n    if (!open) {\n      return undefined;\n    }\n\n    /**\n     * @param {KeyboardEvent} nativeEvent\n     */\n    function handleKeyDown(nativeEvent) {\n      if (!nativeEvent.defaultPrevented) {\n        // IE11, Edge (prior to using Blink?) use 'Esc'\n        if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {\n          // not calling `preventDefault` since we don't know if people may ignore this event e.g. a permanently open snackbar\n          onClose == null ? void 0 : onClose(nativeEvent, 'escapeKeyDown');\n        }\n      }\n    }\n    document.addEventListener('keydown', handleKeyDown);\n    return () => {\n      document.removeEventListener('keydown', handleKeyDown);\n    };\n  }, [open, onClose]);\n  const handleClose = useEventCallback((event, reason) => {\n    onClose == null ? void 0 : onClose(event, reason);\n  });\n  const setAutoHideTimer = useEventCallback(autoHideDurationParam => {\n    if (!onClose || autoHideDurationParam == null) {\n      return;\n    }\n    clearTimeout(timerAutoHide.current);\n    timerAutoHide.current = setTimeout(() => {\n      handleClose(null, 'timeout');\n    }, autoHideDurationParam);\n  });\n  React.useEffect(() => {\n    if (open) {\n      setAutoHideTimer(autoHideDuration);\n    }\n    return () => {\n      clearTimeout(timerAutoHide.current);\n    };\n  }, [open, autoHideDuration, setAutoHideTimer]);\n  const handleClickAway = event => {\n    onClose == null ? void 0 : onClose(event, 'clickaway');\n  };\n\n  // Pause the timer when the user is interacting with the Snackbar\n  // or when the user hide the window.\n  const handlePause = () => {\n    clearTimeout(timerAutoHide.current);\n  };\n\n  // Restart the timer when the user is no longer interacting with the Snackbar\n  // or when the window is shown back.\n  const handleResume = React.useCallback(() => {\n    if (autoHideDuration != null) {\n      setAutoHideTimer(resumeHideDuration != null ? resumeHideDuration : autoHideDuration * 0.5);\n    }\n  }, [autoHideDuration, resumeHideDuration, setAutoHideTimer]);\n  const createHandleBlur = otherHandlers => event => {\n    const onBlurCallback = otherHandlers.onBlur;\n    onBlurCallback == null ? void 0 : onBlurCallback(event);\n    handleResume();\n  };\n  const createHandleFocus = otherHandlers => event => {\n    const onFocusCallback = otherHandlers.onFocus;\n    onFocusCallback == null ? void 0 : onFocusCallback(event);\n    handlePause();\n  };\n  const createMouseEnter = otherHandlers => event => {\n    const onMouseEnterCallback = otherHandlers.onMouseEnter;\n    onMouseEnterCallback == null ? void 0 : onMouseEnterCallback(event);\n    handlePause();\n  };\n  const createMouseLeave = otherHandlers => event => {\n    const onMouseLeaveCallback = otherHandlers.onMouseLeave;\n    onMouseLeaveCallback == null ? void 0 : onMouseLeaveCallback(event);\n    handleResume();\n  };\n  React.useEffect(() => {\n    // TODO: window global should be refactored here\n    if (!disableWindowBlurListener && open) {\n      window.addEventListener('focus', handleResume);\n      window.addEventListener('blur', handlePause);\n      return () => {\n        window.removeEventListener('focus', handleResume);\n        window.removeEventListener('blur', handlePause);\n      };\n    }\n    return undefined;\n  }, [disableWindowBlurListener, handleResume, open]);\n  const getRootProps = (otherHandlers = {}) => {\n    const propsEventHandlers = extractEventHandlers(parameters);\n    const externalEventHandlers = _extends({}, propsEventHandlers, otherHandlers);\n    return _extends({\n      ref,\n      // ClickAwayListener adds an `onClick` prop which results in the alert not being announced.\n      // See https://github.com/mui/material-ui/issues/29080\n      role: 'presentation'\n    }, externalEventHandlers, {\n      onBlur: createHandleBlur(externalEventHandlers),\n      onFocus: createHandleFocus(externalEventHandlers),\n      onMouseEnter: createMouseEnter(externalEventHandlers),\n      onMouseLeave: createMouseLeave(externalEventHandlers)\n    });\n  };\n  return {\n    getRootProps,\n    onClickAway: handleClickAway\n  };\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,yBAAyB,IAAIC,gBAAgB,QAAQ,YAAY;AAC1E,OAAOC,oBAAoB,MAAM,+BAA+B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAW,CAACC,UAAU,EAAE;EAC9C,MAAM;IACJC,gBAAgB,GAAG,IAAI;IACvBC,yBAAyB,GAAG,KAAK;IACjCC,OAAO;IACPC,IAAI;IACJC,GAAG;IACHC;EACF,CAAC,GAAGN,UAAU;EACd,MAAMO,aAAa,GAAGZ,KAAK,CAACa,MAAM,EAAE;EACpCb,KAAK,CAACc,SAAS,CAAC,MAAM;IACpB,IAAI,CAACL,IAAI,EAAE;MACT,OAAOM,SAAS;IAClB;;IAEA;AACJ;AACA;IACI,SAASC,aAAa,CAACC,WAAW,EAAE;MAClC,IAAI,CAACA,WAAW,CAACC,gBAAgB,EA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